cmake_minimum_required(VERSION 3.20)

project(cpp_learn_template_srsj
    VERSION 1.0.0
    DESCRIPTION "C++ Learning Project with Templates and Advanced Features"
    LANGUAGES CXX
)

# Set C++ standard
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Set build type to Debug if not specified
if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Debug)
endif()

# Export compile commands for IDE support
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Compiler-specific options
if(MSVC)
    add_compile_options(/W4 /permissive-)
    # Enable C++20 modules for MSVC
    add_compile_options(/experimental:module)
else()
    add_compile_options(-Wall -Wextra -Wpedantic)
    # Enable C++20 modules for GCC/Clang
    if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
        add_compile_options(-fmodules-ts)
    elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
        add_compile_options(-fmodules)
    endif()
endif()

# Add subdirectories
add_subdirectory(cpp_basic)
add_subdirectory(template-cpp-learn)
add_subdirectory(testCode)
add_subdirectory(learn_boost)
add_subdirectory(learn_double)

# Print build configuration
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "C++ standard: ${CMAKE_CXX_STANDARD}")
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}")
